name: solvespace
base: core22
summary: Parametric 2d/3d CAD
adopt-info: solvespace
description: |
  SOLVESPACE is a free (GPLv3) parametric 3d CAD tool.
  Applications include
  * modeling 3d parts — draw with extrudes, revolves, and Boolean (union / difference) operations
  * modeling 2d parts — draw the part as a single section, and export DXF, PDF, SVG; use 3d assembly to verify fit
  * 3d-printed parts — export the STL or other triangle mesh expected by most 3d printers
  * preparing CAM data — export 2d vector art for a waterjet machine or laser cutter; or generate STEP or STL, for import into third-party CAM software for machining
  * mechanism design — use the constraint solver to simulate planar or spatial linkages, with pin, ball, or slide joints
  * plane and solid geometry — replace hand-solved trigonometry and spreadsheets with a live dimensioned drawing

confinement: strict
license: GPL-3.0
compression: lzo
grade: stable

layout:
  /usr/share/solvespace:
    symlink: $SNAP/usr/share/solvespace

apps:
  solvespace:
    command: usr/bin/solvespace
    desktop: solvespace.desktop
    extensions: [gnome]
    plugs: [opengl, unity7, home, removable-media, gsettings, network]
  cli:
    command: usr/bin/solvespace-cli
    extensions: [gnome]
    plugs: [home, removable-media, network]

parts:
  solvespace:
    plugin: cmake
    source: ./solvespace-snap-src
    source-type: local
    override-pull: |
      craftctl default
      git submodule update --init extlib/libdxfrw extlib/mimalloc extlib/eigen
    override-build: |
      craftctl default
      project_version=$(grep CMAKE_PROJECT_VERSION:STATIC CMakeCache.txt | cut -d "=" -f2)
      cd $CRAFT_PART_SRC
      version="$project_version~$(git rev-parse --short=8 HEAD)"
      craftctl set version="$version"
    cmake-parameters:
      - -DCMAKE_INSTALL_PREFIX=/usr
      - -DCMAKE_BUILD_TYPE=Release
      - -DENABLE_TESTS=OFF
      - -DSNAP=ON
      - -DENABLE_OPENMP=ON
      - -DENABLE_LTO=ON
    build-packages:
      - zlib1g-dev
      - libpng-dev
      - libcairo2-dev
      - libfreetype6-dev
      - libjson-c-dev
      - libgl-dev
      - libsigc++-2.0-dev
      - libspnav-dev
      - git
      - g++
      - libc6-dev
    stage-packages:
      - libspnav0
      - libsigc++-2.0-0v5

  cleanup:
    after: [solvespace]
    plugin: nil
    build-snaps: [gnome-42-2204]
    override-prime: |
      set -eux
      for snap in "gnome-42-2204"; do  # List all content-snaps you're using here
        cd "/snap/$snap/current" && find . -type f,l -exec rm -f "$CRAFT_PRIME/{}" "$CRAFT_PRIME/usr/{}" \;
      done
      for cruft in bug lintian man; do
        rm -rf $CRAFT_PRIME/usr/share/$cruft
      done
      find $CRAFT_PRIME/usr/share/doc/ -type f -not -name 'copyright' -delete
      find $CRAFT_PRIME/usr/share -type d -empty -delete
